package com.study.base.cas;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @description: CasDemo
 * @date: 2021/1/28 16:17
 * @author: hcm
 * @version: 1.0
 */
public class CasDemo {
    public static void main(String[] args) {
        AtomicInteger atomicInteger = new AtomicInteger(5);
        System.out.println(atomicInteger.compareAndSet(5, 2021)+"\t current data:"+ atomicInteger.get());
        System.out.println(atomicInteger.compareAndSet(2021, 2121)+"\t current data:"+ atomicInteger.get());
        atomicInteger.getAndIncrement();
    }
}
